package com.aurora.source.home.activity;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.aurora.source.R;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.base.BaseWhiteToolbarActivity;
import com.aurora.source.center.activity.SourceCenterMainActivity;
import com.aurora.source.home.fragment.ContactUsFragment;
import com.aurora.source.home.fragment.DetectionFragment;
import com.aurora.source.home.fragment.EnterpriseProfileFragment;
import com.aurora.source.home.fragment.QualificationHonorFragment;
import com.aurora.source.source.activity.SettingActivity;
import com.aurora.source.util.DpPxUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 企业信息
 */
public class EnterpriseInformationActivity extends BaseWhiteToolbarActivity {

    @BindView(R.id.tv_center)
    TextView tvCenter;
    @BindView(R.id.fl_content)
    FrameLayout flContent;
    @BindView(R.id.tv_enterprise_profile)
    TextView tvEnterpriseProfile;
    @BindView(R.id.tv_contact_us)
    TextView tvContactUs;
    @BindView(R.id.tv_detection)
    TextView tvDetection;
    @BindView(R.id.iv_home)
    ImageView ivHome;
    @BindView(R.id.tv_home)
    TextView tvHome;
    @BindView(R.id.ll_home)
    LinearLayout llHome;
    @BindView(R.id.iv_source)
    ImageView ivSource;
    @BindView(R.id.tv_source)
    TextView tvSource;
    @BindView(R.id.ll_source)
    LinearLayout llSource;
    @BindView(R.id.iv_setting)
    ImageView ivSetting;
    @BindView(R.id.tv_setting)
    TextView tvSetting;
    @BindView(R.id.ll_setting)
    LinearLayout llSetting;
    private EnterpriseProfileFragment enterpriseProfileFragment;

    @Override
    public BasePresenter attach() {
        return null;
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_enterprise_information;
    }

    @Override
    public void initData(@Nullable Bundle bundle) {

    }

    @Override
    public void initView(Bundle savedInstanceState, View contentView) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        tvEnterpriseProfile.setSelected(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            tvEnterpriseProfile.setElevation(DpPxUtil.dp2px(activity, 10));
            tvCenter.setElevation(0);
            tvDetection.setElevation(0);
            tvContactUs.setElevation(0);
        }
        enterpriseProfileFragment = new EnterpriseProfileFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_content, enterpriseProfileFragment).commit();


        simpleToolbar.setMainTitle("企业信息");
        simpleToolbar.setLeftVisibility(View.VISIBLE);

    }

    @Override
    public void doBusiness() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.ll_home, R.id.ll_source, R.id.ll_setting, R.id.tv_enterprise_profile, R.id.tv_center, R.id.tv_detection, R.id.tv_contact_us})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_home:
                hideSoftInput();
                finish();
                break;
            case R.id.ll_source:
                gotoActivity(SourceCenterMainActivity.class, false);
                break;
            case R.id.ll_setting:
                gotoActivity(SettingActivity.class, false);
                break;
            case R.id.tv_enterprise_profile://企业简介
                EnterpriseProfileFragment enterpriseProfileFragment;
                tvEnterpriseProfile.setSelected(true);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    tvEnterpriseProfile.setElevation(DpPxUtil.dp2px(activity, 10));
                    tvCenter.setElevation(0);
                    tvDetection.setElevation(0);
                    tvContactUs.setElevation(0);
                }
                tvCenter.setSelected(false);
                tvDetection.setSelected(false);
                tvContactUs.setSelected(false);
                enterpriseProfileFragment = new EnterpriseProfileFragment();
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_content, enterpriseProfileFragment).commit();

                break;
            case R.id.tv_center://资质荣誉
                QualificationHonorFragment qualificationHonorFragment;
                tvEnterpriseProfile.setSelected(false);
                tvDetection.setSelected(false);
                tvContactUs.setSelected(false);
                tvCenter.setSelected(true);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    tvEnterpriseProfile.setElevation(0);
                    tvCenter.setElevation(DpPxUtil.dp2px(activity, 10));
                    tvDetection.setElevation(0);
                    tvContactUs.setElevation(0);
                }
                qualificationHonorFragment = new QualificationHonorFragment();
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_content, qualificationHonorFragment).commit();
                break;
            case R.id.tv_detection://检测检疫
                DetectionFragment detectionFragment;
                tvEnterpriseProfile.setSelected(false);
                tvCenter.setSelected(false);
                tvDetection.setSelected(true);
                tvContactUs.setSelected(false);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    tvEnterpriseProfile.setElevation(0);
                    tvCenter.setElevation(0);
                    tvDetection.setElevation(DpPxUtil.dp2px(activity, 10));
                    tvContactUs.setElevation(0);
                }
                //        tvContactUs.setSelected(tvContactUs.isSelected());
                detectionFragment = new DetectionFragment();
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_content, detectionFragment).commit();

                break;
            case R.id.tv_contact_us://联系我们
                ContactUsFragment contactUsFragment;
                tvEnterpriseProfile.setSelected(false);
                tvCenter.setSelected(false);
                tvDetection.setSelected(false);
                tvContactUs.setSelected(true);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    tvEnterpriseProfile.setElevation(0);
                    tvCenter.setElevation(0);
                    tvDetection.setElevation(0);
                    tvContactUs.setElevation(DpPxUtil.dp2px(activity, 10));
                }
                contactUsFragment = new ContactUsFragment();
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_content, contactUsFragment).commit();

                break;
        }
    }
}
